package com.htao.train.common.context;

import com.htao.train.common.resp.MemberLoginResp;
import lombok.extern.slf4j.Slf4j;

import java.util.Stack;

/**
 * @Author： HTTT
 * @Date： 2024/1/5 21:07
 * @Describe：
 */
@Slf4j
public class LoginMemberContext {
    private static ThreadLocal<MemberLoginResp> member = new ThreadLocal<>();
    public static MemberLoginResp getMember(){
        return member.get();
    }
    public static void setMember(MemberLoginResp member){
        LoginMemberContext.member.set(member);
    }
    public static Long getId(){
        try {
            return member.get().getId();
        }catch (Exception e){
            log.error("获取会员登录信息异常",e);
            throw e;
        }
    }
}
